package com.gh.lambda;

import javax.swing.*;
import javax.swing.Timer;
import java.util.*;
import java.util.Date;

/**
 * @author M.G
 * @create 2022-12-08 22:04
 */
public class LambdaTest {

    public static void main(String[] args) {

        String[] planets = new String[]{"one","two","three","four","five"};
        System.out.println(Arrays.toString(planets));
        System.out.println("按字典顺序排序：");
        Arrays.sort(planets);
        System.out.println(Arrays.toString(planets));
        System.out.println("按长度排序");


        //sort默认从小到大排序，返回值是-1（前面比后面短），0（一样长），1（前面比后面长），从而排序
        Arrays.sort(planets,(String second,String first) -> first.length() - second.length());
        System.out.println(Arrays.toString(planets));

        Timer timer = new Timer(1000,event ->
                System.out.println("时间是："+ new Date()));
        timer.start();

        JOptionPane.showMessageDialog(null,"Quit Program?");
        System.exit(0);

    }
}
